/**
 * 
 */
package de.oszimtcc.timetablecore;

import java.util.Date;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import de.oszimtcc.timetablecore.Block.BlockType;


/**
 * @author Kooki
 *
 */
public class DayFactory
{
	public static Day DayFromNode(Node pNode, int pDayIndex, Date pDayDate)
	{
		Element thisDay = (Element)pNode;
		Day toReturn = new Day(pDayIndex,pDayDate);
		NodeList blockNodes = thisDay.getElementsByTagName("block");
        for (int i = 0; i < blockNodes.getLength(); i++)
        {
			Element actualBlock = (Element)blockNodes.item(i);
			if(actualBlock.getTextContent().replace(" ","").length() >= 1)
			{
				Block tmp = new Block(actualBlock);		
				//if(tmp.GetBlockType() != BlockType.Free)
					toReturn.BlockList.add(tmp);
			}
        }
        
        return toReturn;
	}
}
